package com.yoso.starter.boot.util.file;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.file.FileNameUtil;
import cn.hutool.core.lang.Assert;
import com.yoso.starter.boot.util.file.param.WatermarkDO;

import java.io.File;

public abstract class AbstractWatermarkHandler implements WatermarkHandler {

    public static WatermarkHandler getHandler(WatermarkDO watermarkDO) {
        File file = FileUtil.file(watermarkDO.getSrcPath());
        Assert.isTrue(file.exists(), "文件不存在");
        String suffix = FileNameUtil.getSuffix(file.getName());
        if (suffix.equals("pdf")) {
            return new PDFWatermarkHandler();
        }
        return null;
    }


}
